package com.ramotion.expandingcollection;

import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.PageSliderProvider;

import java.util.List;

/**
 * MySliderProvier
 *
 * @since 2021-06-21
 */
public abstract class EcPagerViewAdapter extends PageSliderProvider {
    private List<EcCardData> list;

    /**
     * EcPagerViewAdapter
     *
     * @param list
     */
    public EcPagerViewAdapter(List<EcCardData> list) {
        this.list = list;
    }

    /**
     * getCount
     *
     * @return size
     */
    @Override
    public int getCount() {
        return list.size();
    }

    /**
     * createPageInContainer
     *
     * @param componentContainer
     * @param i
     * @return dd
     */
    @Override
    public Object createPageInContainer(ComponentContainer componentContainer, int i) {
        instantiateCard(componentContainer, i, list.get(i));
        return componentContainer;
    }

    /**
     * instantiateCard
     *
     * @param componentContainer
     * @param i
     * @param data
     */
    public abstract void instantiateCard(ComponentContainer componentContainer, int i, EcCardData data);

    /**
     * destroyPageFromContainer
     *
     * @param componentContainer
     * @param i
     * @param o
     */
    @Override
    public void destroyPageFromContainer(ComponentContainer componentContainer, int i, Object o) {
        componentContainer.removeComponent((Component) o);
    }

    /**
     * isPageMatchToObject
     *
     * @param component
     * @param o
     * @return false
     */
    @Override
    public boolean isPageMatchToObject(Component component, Object o) {
        return true;
    }
}
